




FromMatchesFilter(std::string address) :
	address(address)
{
	if (address.empty()) {
		//throw new IllegalArgumentException("Parameter cannot be null.");
	}
	std::transform(address.begin(), address.end(), address.begin(), ::tolower);
	matchBareJID = StringUtils::parseResource(address) == "";
}


bool accept(Packet * packet) {
	if (packet->getFrom().empty()) {
		return false;
	}
	else if (matchBareJID) {
		// Check if the bare JID of the sender of the packet matches the specified JID
		std::string from = packet->getFrom();
		std::transform(from.begin(), from.end(), from.begin(), ::tolower);

		return from.find(address) == 0;
	}
	else {
		// Check if the full JID of the sender of the packet matches the specified JID
		std::string from = packet->getFrom();
		std::transform(from.begin(), from.end(), from.begin(), ::tolower);
		return address == from;
	}
}
